<?php
namespace App\Http\Logic\Api;



use App\Models\AdminApply;

class ImportLogic
{
    public function import($data){
        try{
            $result = [];
            foreach($data as $v){
                $result[] = [
                    'status' => 1,
                    'user_id' => 0,
                    'user_name' => $v['name'] ?? '',
                    'id_card_number' => $v['idNumber'] ?? '',
                    'phone' => $v['phone'],
                    'source' => $v['source'] ?? '',
                    'work_type' => $v['jobType'] ?? '',
                    'level' => $v['level'] ?? '',
                    'age'=>$v['age'] ?? '',
                    'work_experience'=> $v['workExperience'] ?? '',
                    'card_front_image'=>$v['idFront'] ?? '',
                    'card_back_image'=>$v['idBack'] ?? '',
                    'head_image'=>$v['photo'] ?? '',
                    'diploma_image'=>$v['education'] ?? '',
                    'social_security_image'=>$v['socialSecurity'] ?? '',
                    'skill_image'=>$v['skillCertificate'] ?? '',
                    'sex'=>$v['gender']=='男' ? 1 : 2,
                    'company'=>$v['company'] ?? '',
                    'created_at' => date('Y-m-d H:i:s'),
                    'updated_at' => date('Y-m-d H:i:s'),
                ];
            }
            if(!empty($result)){
                AdminApply::insert($result);
            }
            return $result;
        }catch (\Exception $e){
            throw $e;
        }
    }
}
